<%--
  Created by IntelliJ IDEA.
  User: zjk
  Date: 2018-08-04
  Time: 14:42
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>添加商品</title>
    <link rel="shortcut icon" href="easyui/css/images/favicon.ico" />
    <link rel="stylesheet" href="css/flipclock.css">
    <link href="css/CalcSS3.css" rel="stylesheet" type="text/css" />
    <link href="css/index.css" rel="stylesheet" type="text/css" />
    <link href="easyui/css/easyui.css" rel="stylesheet" type="text/css">
    <link href="easyui/css/easyui_animation.css" rel="stylesheet" type="text/css">
    <link href="easyui/css/easyui_plus.css" rel="stylesheet" type="text/css">
    <link href="easyui/css/insdep_theme_default.css" rel="stylesheet" type="text/css">
    <link href="easyui/css/icon.css" rel="stylesheet" type="text/css">
    <link href="easyui/css/font-awesome-4.7.0/css/font-awesome.min.css" rel="stylesheet" type="text/css">

    <!-- 引入 ECharts 文件 -->
    <script src="js/echarts.js"></script>
    <!--放入自定义的图表-->
    <script src="js/monitor.js"></script>
    <script type="text/javascript" src="easyui/js/jquery.min.js"></script>
    <script type="text/javascript" src="easyui/js/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="easyui/js/jquery.insdep-extend.min.js"></script>
</head>
<body>

<div class="easyui-layout"  data-options="fit:true, border:false">
    <div data-options="region:'center'" style="padding:5px;">
        <form id="zjk-offer-add-detail-f">
        <table class="utils-table" border="0" style="background-color: #EBEFF2;">


            <tr>
                <td>产品名称：</td>
                <td  class="content-td" style="text-align: left;" ><input id="zjk-offer-add-detail-pname"  class="easyui-combobox" data-options="editable:false"/></td>
                <td>产品编号：</td>
                <td  class="content-td" style="text-align: left;" ><input id="zjk-offer-add-detail-pId" name="pId" class="easyui-textbox" data-options="editable:false"/></td>
            </tr>
            <tr>
                <td>单位：</td>
                <td  class="content-td" style="text-align: left;" ><input id="zjk-offer-add-detail-pwunit"  class="easyui-textbox" data-options="editable:false"/></td>
                <td>单价：</td>
                <td  class="content-td" style="text-align: left;" ><input id="zjk-offer-add-detail-poprice"  class="easyui-textbox" data-options="editable:false"/></td>
            </tr>
            <tr>
                <td>数量：</td>
                <td class="content-td" style="text-align: left;" ><input id="zjk-offer-add-detail-counts" name="counts" class="easyui-textbox" data-options=""validType="checkNumber"/></td>
                <td>总金额：</td>
                <td class="content-td" style="text-align: left;" ><input id="zjk-offer-add-detail-totalMoney" name="totalMoney" class="easyui-textbox" data-options="editable:false"validType="checkDotNumber"/></td>
                <td>创建时间：</td>
                <td class="content-td" style="text-align: left;" ><input id="zjk-offer-add-detail-setTime" name="setTime" class="easyui-datebox" data-options="editable:false"/>
                    <input id="ofId" name="ofId" type="hidden" >
                </td>
            </tr>
            <tr>

            </tr>

        </table>
        </form>
    </div>
</div>
<script type="text/javascript">
    $.extend($.fn.validatebox.defaults.rules, {
        checkDotNumber: {
            validator: function (value) {
                var pattern = /^\d+([.]\d+)*$/
                return pattern.test(value);
            },
            message: '必须为数字或小数'
        }
    });
    $.extend($.fn.validatebox.defaults.rules, {
        checkNumber: {
            validator: function (value) {
                var patrn = /^\d+$/;
                return patrn.test(value);
            },
            message: '必须为数字'
        }
    });

    $("#zjk-offer-add-detail-pname").combobox({
        url: 'saling/fuzzyQueryProductDetailsList',
        valueField: 'pid',
        textField: 'pname',
        prompt: '输入关键字后搜索',
        required: true,
        mode: 'remote',
        editable: true,
        method: 'post',
        hasDownArrow: false,
        limitToList: true,
        onBeforeLoad: function (param) {
            var value = $(this).combobox('getValue');
            if (value) {
                return true;
            }
            return false;
        },
        onSelect: function (rec) {
            $.post('saling/exactQueryProductDetail', {id: rec.pid}, function (r) {
                if (r) {
                    $("#zjk-offer-detail-dg").datagrid({'productDetail': r});
                    $("#zjk-offer-add-detail-pId").textbox({
                        value: r.pid
                    });
                    $("#zjk-offer-add-detail-poprice").textbox({
                        value: r.poprice
                    });
                    $("#zjk-offer-add-detail-pwunit").textbox({
                        value: r.pwunit
                    });

                    $("#zjk-offer-add-detail-counts").textbox({
                        onChange: function (a, b) {
                            var c = $("#zjk-offer-add-detail-poprice").textbox("getValue");
                            $("#zjk-offer-add-detail-totalMoney").textbox({
                                value: c * a,
                            });
                        }
                    });
                    $("#zjk-offer-add-detail-poprice").textbox({
                        onChange: function (a, b) {
                            var c = $("#zjk-offer-add-detail-counts").textbox("getValue");
                            $("#zjk-offer-add-detail-totalMoney").textbox({
                                value: c * a,
                            });
                        }

                    });

                }
            });

        }
    });
    $("#ofId").val($("input[name='ofId']").val());


</script>
</body>
</html>
